import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    children: [
      {
        path: '/chats',
        name: 'Chats',
        component: () => import('../views/home/chats/index.vue'),
        children: [
          {
            path: '/chatFrame',
            name: 'ChatFrame',
            component: () => import('../views/chatFrame/index.vue'),
            meta: {
              sidebarIndex: 0
            }
          }
        ]
      },
      {
        path: '/friend',
        name: 'Friend',
        component: () => import('../views/home/friend/index.vue'),
        children: [
          {
            path: '/friendUser',
            name: 'FriendUser',
            component: () => import('../views/friend/friendUser/index.vue'),
            meta: {
              sidebarIndex: 1
            },
          }
        ]
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/login')
  }
]

const router = new VueRouter({
  routes
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


export default router
